package com.shux.inventory.biz.impl;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shux.inventory.biz.InventoryProductBiz;
import com.shux.inventory.entity.InventoryProduct;
import com.shux.inventory.mapper.InventoryProductMapper;
import com.shux.redis.biz.IRedisBiz;

/**
 **********************************************
 *  描述
 * Simba.Hua
 * 2017年8月30日
 **********************************************
**/
@Service("inventoryProductBiz")
public class InventoryProductBizImpl implements InventoryProductBiz {
    private @Autowired IRedisBiz<InventoryProduct> redisBiz;
    private @Resource InventoryProductMapper mapper;
    @Override
    public void updateInventoryProduct(InventoryProduct inventoryProduct) {
        // TODO Auto-generated method stub
        mapper.updateInventoryProduct(inventoryProduct);
    }

    @Override
    public InventoryProduct loadInventoryProductByProductId(Integer productId) {
        // TODO Auto-generated method stub
        return mapper.loadInventoryProductByProductId(productId);
    }

    @Override
    public void setInventoryProductCache(InventoryProduct inventoryProduct) {
        redisBiz.set("inventoryProduct:"+inventoryProduct.getProductId(), inventoryProduct);
        
    }

    @Override
    public void removeInventoryProductCache(Integer productId) {
        redisBiz.delete("inventoryProduct:"+productId);
        
    }

    @Override
    public InventoryProduct loadInventoryProductCache(Integer productId) {
        // TODO Auto-generated method stub
        return redisBiz.get("inventoryProduct:"+productId);
    }

}
